<template>
	<view>
		<view class="boxes" v-for="(item,index) in list" :key="index" @click.stop="detail(item.id)">
			<view class="uniBtn box">
				<view>订单号：{{item.id}}</view>
				<view class="stu" v-if="item.status==0">待支付</view>
				<view class="stu" v-else-if="item.status==1">已付款</view>
				<view class="stu" v-else>已取消</view>
			</view>
			<view class="uniFlex2 box2">
				<view>患者姓名</view>
				<view>{{item.name}}</view>
			</view>
			<view class="uniFlex2 box2">
				<view>收费项目</view>
				<view>{{item.item}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		myWzf
	} from '@/request/api.js'
	export default {
		data() {
			return {
				// 上拉加载
				page: 1,
				pages: 0,
				list: []
			}
		},
		onLoad() {
			this.getList(1);
		},
		onReachBottom: function() {
			//触底的时候请求数据，即为上拉加载更多
			this.page++;
			if (this.page > this.pages) {
				uni.hideNavigationBarLoading();
				uni.showToast({
					title: '暂无更多数据',
					icon: 'none'
				})
			} else {
				this.getList(this.page);
			}
		},
		methods: {
			detail(id){
				uni.navigateTo({
					url:'./detail?id='+id
				})
			},
			// 列表
			getList(page) {
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				myWzf({
					page: page,
					listRows: 10,
				}).then(res => {
					this.pages = res.totalPages;
					if (this.page == 1) {
						this.list = res.data;
						if (this.list.length === 0 || this.list.length === '0') {
							uni.showToast({
								icon: 'none',
								duration: 3000,
								title: '暂无数据'
							});
							return
						}
					} else {
						this.list = this.list.concat(res.data);
					}
					uni.hideLoading()
					uni.hideNavigationBarLoading()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background: #f8f8f8;
		padding-top: 20rpx;
	}
	.boxes{
		background: #ffffff;
		margin-bottom: 20upx;
		padding: 20upx 30upx;
		font-size: 28upx;
		color: #000;
		
		.box{
			border-bottom: 1px solid #eee;
			padding-bottom: 20upx;
			
			view:first-child{
				color: #000;
				font-weight: 520;
			}
			view:last-child{
				color: #F63B18;
				background-color: #FDF4F5;
				border-radius: 30upx;
				padding: 10upx 26upx;
				font-size: 24upx;
			}
		}
		.box2{
			margin: 30upx 0;
			
			view:first-child{
				color: #797979;
				width: 160upx;
			}
			view:last-child{
				flex: 1;
			}
		}
		.box3{
			margin: 30upx 0;
			
			view:first-child{
				color: #6996FE;
				font-size: 24upx;
				border:1px solid #6996FE;
				border-radius: 26upx;
				padding: 8upx 30upx;
			}
			.last1{
				background-color: #6996FE;
				color: #fff;
				border-radius: 40upx;
				padding: 15upx 30upx;
			}
			.last2{
				border: 1px solid #E0E0E0;
				color: #818181;
				border-radius: 40upx;
				padding: 15upx 30upx;
			}
		}
	}
</style>
